package com.zzk.audiovideodemo

import android.app.Application
import android.content.Context
import android.content.res.Configuration
import androidx.camera.camera2.Camera2Config
import androidx.camera.core.CameraXConfig
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.Utils
import org.jetbrains.annotations.NotNull

/**
 *
 * @ProjectName:    AudioVideoDemo
 * @Package:        com.zzk.audiovideodemo
 * @ClassName:      MyApplication
 * @Description:
 * @Author:         brilliantzhao
 * @CreateDate:     2021.3.8 16:49
 * @UpdateUser:
 * @UpdateDate:     2021.3.8 16:49
 * @UpdateRemark:
 * @Version:        1.0.0
 */

class MyApplication : Application(), CameraXConfig.Provider {

    companion object {

        var mContext: Application? = null

        fun getContext(): Context {
            return mContext!!
        }
    }

    override fun onCreate() {
        super.onCreate()
        LogUtils.i("MyApplication->onCreate")
        mContext = this
        //
        Utils.init(this)
    }

    override fun onConfigurationChanged(newConfig: Configuration) {
        super.onConfigurationChanged(newConfig)
        LogUtils.i("MyApplication->onConfigurationChanged")
    }

    override fun onLowMemory() {
        super.onLowMemory()
        LogUtils.i("MyApplication->onLowMemory")
    }

    override fun onTrimMemory(level: Int) {
        super.onTrimMemory(level)
        LogUtils.i("MyApplication->onTrimMemory level = $level")
    }

    override fun onTerminate() {
        super.onTerminate()
        LogUtils.i("MyApplication->onTerminate")
    }

    @NotNull
    override fun getCameraXConfig(): CameraXConfig {
        return Camera2Config.defaultConfig()
    }
}